<template>
    <div class="content-left">
      <van-sidebar v-model="active">
        <van-sidebar-item v-for="(item,index) in list" :title="item.title" :key="index" @click="onChange(index)"/>
      </van-sidebar>
    </div>
</template>
<script>

import {CategoryData} from "@/network/category";

export  default {
  name:'CategroyBar',
  data(){
    return {
      active:0,
      currentIndex:0,
      list:[]
    }
  },
  created() {
    this.CategoryData()
  },
  methods:{
    CategoryData(){
      CategoryData().then(res=>{
        console.log(res)
        this.list=res.data.category.list;
        this.$bus.$emit('onChange',this.list[this.currentIndex])
      })
    },
    onChange(index){
      this.currentIndex=index
      this.$bus.$emit('onChange',this.list[index])
      // this.CategoryData()
    }
  }
}
</script>
<style>
.content-left{
  background: #fdeaea;
  /*display: flex;*/
  /*overflow: hidden;*/
  /*position: absolute;*/
  position: fixed;
  /*left: 0;*/
  /*right: 0;*/
  top: 44px;
  height: 100%;
  padding-bottom: 50px;
  overflow: scroll;
}
</style>
